import { RouteRecordRaw } from "vue-router";
import TestView from "@/views/TestView.vue";
import SearchView from "@/views/SearchView.vue";
import UserLayout from "@/layouts/UserLayout.vue";
import AddArticleView from "@/views/article/AddArticleView.vue";
import UserLoginView from "@/views/user/UserLoginView.vue";
import UserRegisterView from "@/views/user/UserRegisterView.vue";
import AdminView from "@/views/AdminView.vue";

export const routes: Array<RouteRecordRaw> = [
  {
    path: "/user",
    name: "用户",
    component: UserLayout,
    children: [
      {
        path: "/user/login",
        name: "用户登录",
        component: UserLoginView,
      },
      {
        path: "/user/register",
        name: "用户注册",
        component: UserRegisterView,
      },
    ],
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/search",
    name: "聚合搜索",
    component: SearchView,
  },
  {
    path: "/",
    name: "默认",
    redirect: "/about",
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/:category",
    component: SearchView,
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/add/article",
    name: "创作社区",
    component: AddArticleView,
    meta: {
      // access: ACCESS_ENUM.USER,
    },
  },
  {
    path: "/about",
    name: "个人中心",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/UserCenter.vue"),
  },
  {
    path: "/hide",
    name: "测试面板",
    component: TestView,
    meta: {
      // hideInMenu: true,
    },
  },
  {
    path: "/admin",
    name: "管理员可见",
    component: AdminView,
    meta: {
      // access: ACCESS_ENUM.ADMIN,
    },
  },
];
